/**
 * class  BaseRadio
 * 单选框基类，通过此类，可自定义Radio
 * author haicent
 * email haicent@126.com
 * version 0.01
 */
package as3.component.support
{
	import flash.events.MouseEvent;
	
	import as3.component.controls.RadioGroup;
	
	public class BaseRadio extends BaseToggleButton
	{
		protected var _value:*;
		
		private var _radioGroup:RadioGroup;
		
		public function BaseRadio(radioGroupValue:RadioGroup = null)
		{
			super();
			group = radioGroupValue;
		}
		
		override protected function initUI():void
		{
			super.initUI();
			_uiLibrary["upImage"] = "Radio_upSkin";
			_uiLibrary["overImage"] = "Radio_overSkin";
			_uiLibrary["downImage"] = "Radio_downSkin";
			_uiLibrary["disabledImage"] = "Radio_disabledSkin";
			
			_uiLibrary["selectUpImage"] = "Radio_selectUpSkin";
			_uiLibrary["selectOverImage"] = "Radio_selelctOverSkin";
			_uiLibrary["selectDownImage"] = "Radio_selectDownSkin";
			_uiLibrary["selectDisabledImage"] = "Radio_selelctDisabledSkin";
		}
		
		public function set value(value:*):void
		{
			_value = value;
		}
		
		public function get value():*
		{
			return _value;
		}
		
		public function set group(groupValue:RadioGroup):void
		{
			if (groupValue == null || _radioGroup == groupValue) return;
			if (_radioGroup)
			{
				_radioGroup.remove(this);
			}
			_radioGroup = groupValue;
			_radioGroup.put(this);
		}
		
		public function get group():RadioGroup
		{
			return _radioGroup;
		}
		
		override public function set width(value:Number) : void
		{
			super.width = value;
		}
		
		override public function set height(value:Number) : void
		{
			super.height = value;
		}
		
		override protected function $onMouseUpHandler(evt:MouseEvent):void
		{
			if (group)
			{
				group.selelct(this);
			} else {
				selected = true;
			}
		}
		
	}
}